package servlet;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import common.Servlet;
import common.Validate;
import dict.TransactionDict;
import dicts.RealmDict;
import util.HttpUtil;
import util.LogUtil;
import util.RequestUtil;
import utils.DateUtil;

public class Entrance extends Servlet {

	private static final long serialVersionUID = 1L;

	public void process(HttpServletRequest request, HttpServletResponse response) throws Exception {

		try {
			String result = new HttpUtil().post(RealmDict.GATEWAY + "Entrance", RequestUtil.transferMap(request));
			LogUtil.entrance(DateUtil.format(new Date(), DateUtil.DATETIMENOSPACE) + " " + RealmDict.GATEWAY + "Entrance?" + RequestUtil.transferString(request));
			response.getWriter().print(result);
			LogUtil.entrance(DateUtil.format(new Date(), DateUtil.DATETIMENOSPACE) + " " + result);
			return;
		} catch (Exception e) {
			LogUtil.entrance(DateUtil.format(new Date(), DateUtil.DATETIMENOSPACE) + " " + e.getMessage());
			response.getWriter().print(Validate.result(TransactionDict.CONNECTION_EXCEPTION, TransactionDict.MESSAGES.get(TransactionDict.CONNECTION_EXCEPTION)));
			return;
		}

	}

}
